﻿// ReSharper disable once CheckNamespace

/*
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Collections.Generic;

public static class StaticInitializer
{
    /// <summary>
    /// 表示StaticInitializer的静态构造函数是否已被触发
    /// </summary>
    public static bool IsInit { get; } = false;

    static StaticInitializer()
    {
        // 获取当前程序集
        Assembly assembly = Assembly.GetExecutingAssembly();

        // 获取所有public static类
        var staticClasses = GetPublicStaticClasses(assembly);

        // 触发所有public static类的静态构造函数
        foreach (Type type in staticClasses)
        {
            if (type != typeof(StaticInitializer)) // 避免递归触发自身
            {
                RuntimeHelpers.RunClassConstructor(type.TypeHandle);
            }
        }

        // 最后设置初始化标志
        IsInit = true;
    }

    /// <summary>
    /// 获取程序集中所有的public static类
    /// </summary>
    private static IEnumerable<Type> GetPublicStaticClasses(Assembly assembly)
    {
        foreach (Type type in assembly.GetTypes())
        {
            // 检查是否为public、static（抽象且密封）类
            if (type is { IsClass: true, IsPublic: true, IsAbstract: true, IsSealed: true })
            {
                yield return type;
            }
        }
    }
}*/